CSharpTest.Net
UnloadCache Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.BPlusTree Assembly > CSharpTest.Net.Collections Namespace > BPlusTree<TKey,TValue> Class : UnloadCache Method

Glossary Item Box

Safely removes all items from the in-memory cache.

Syntax

Visual Basic (Declaration) 
Public Sub UnloadCache() 
C# 
public void UnloadCache()

Example

BPlusTree/BPlusTree.Test/BasicTests.cs

C#Copy Code
using (BPlusTree<int, string> data = Create(Options))
{
    data.EnableCount();

    int[][] TestArrays = new int[][]
    {
        new int[] { 10, 18, 81, 121, 76, 31, 250, 174, 24, 38, 246, 79 },
        new int[] { 110,191,84,218,170,217,199,232,184,254,32,90,241,136,181,28,226,69,52 },
    };

    foreach (int[] arry in TestArrays)
    {
        data.Clear();
        Assert.AreEqual(0, data.Count);

        int count = 0;
        foreach (int id in arry)
        {
            data.Add(id, id.ToString());
            Assert.AreEqual(++count, data.Count);
        }

        Assert.AreEqual(arry.Length, data.Count);
        data.UnloadCache();

        foreach (int id in arry)
        {
            Assert.AreEqual(id.ToString(), data[id]);
            data[id] = String.Empty;
            Assert.AreEqual(String.Empty, data[id]);
            
            Assert.IsTrue(data.Remove(id));
            Assert.AreEqual(--count, data.Count);
        }

        Assert.AreEqual(0, data.Count);
    }
}
VB.NETCopy Code
Using data As BPlusTree(Of Integer, String) = Create(Options)
    data.EnableCount()

    Dim TestArrays As Integer()() = New Integer()() {New Integer() {10, 18, 81, 121, 76, 31, _
        250, 174, 24, 38, 246, 79}, New Integer() {110, 191, 84, 218, 170, 217, _
        199, 232, 184, 254, 32, 90, _
        241, 136, 181, 28, 226, 69, _
        52}}

    For Each arry As Integer() In TestArrays
        data.Clear()
        Assert.AreEqual(0, data.Count)

        Dim count As Integer = 0
        For Each id As Integer In arry
            data.Add(id, id.ToString())
            Assert.AreEqual(System.Threading.Interlocked.Increment(count), data.Count)
        Next

        Assert.AreEqual(arry.Length, data.Count)
        data.UnloadCache()

        For Each id As Integer In arry
            Assert.AreEqual(id.ToString(), data(id))
            data(id) = [String].Empty
            Assert.AreEqual([String].Empty, data(id))

            Assert.IsTrue(data.Remove(id))
            Assert.AreEqual(System.Threading.Interlocked.Decrement(count), data.Count)
        Next

        Assert.AreEqual(0, data.Count)
    Next
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys